





// 第四个个页面
$('.select_checkbox_all4').click(function () {
	var t = $(this).prop('checked');
	if (t) {
		$('.select_checkbox_one4').prop('checked', true);
	} else {
		$('.select_checkbox_one4').prop('checked', false);
	}
	calc_money();
});
// 反选
$('.select_checkbox_back_all4').click(function () {
	var ttt = {};
	$('input[name="select_check4"]:checked').each(function(){ 
		ttt[$(this).val()] = '1';
	});
	
	$('input[name="select_check4"]').each(function () {
		var i = $(this).val();
		if (ttt[i]) {
			$(this).prop('checked', false);
		} else {
			$(this).prop('checked', true);
		}
	});
	calc_money();
});
$('.select_checkbox_one4').click(function() {

	if ($('.select_checkbox_one4').length == $('input[name="select_check4"]:checked').length) {
		$('.select_checkbox_all4').prop('checked', true);
	} else {
		$('.select_checkbox_all4').prop('checked', false);
	}
	
	calc_money();
});


// 第三个个页面
$('.select_checkbox_all3').click(function () {
	var t = $(this).prop('checked');
	if (t) {
		$('.select_checkbox_one3').prop('checked', true);
	} else {
		$('.select_checkbox_one3').prop('checked', false);
	}
	calc_money();
});
// 反选
$('.select_checkbox_back_all3').click(function () {
	var ttt = {};
	$('input[name="select_check3"]:checked').each(function(){ 
		ttt[$(this).val()] = '1';
	});
	
	$('input[name="select_check3"]').each(function () {
		var i = $(this).val();
		if (ttt[i]) {
			$(this).prop('checked', false);
		} else {
			$(this).prop('checked', true);
		}
	});
	calc_money();
});
$('.select_checkbox_one3').click(function() {

	if ($('.select_checkbox_one3').length == $('input[name="select_check3"]:checked').length) {
		$('.select_checkbox_all3').prop('checked', true);
	} else {
		$('.select_checkbox_all3').prop('checked', false);
	}
	
	calc_money();
});




// 第二个页面
$('.select_checkbox_all2').click(function () {
	var t = $(this).prop('checked');
	if (t) {
		$('.select_checkbox_one2').prop('checked', true);
	} else {
		$('.select_checkbox_one2').prop('checked', false);
	}
	calc_money();
});
// 反选
$('.select_checkbox_back_all2').click(function () {
	var ttt = {};
	$('input[name="select_check2"]:checked').each(function(){ 
		ttt[$(this).val()] = '1';
	});
	
	$('input[name="select_check2"]').each(function () {
		var i = $(this).val();
		if (ttt[i]) {
			$(this).prop('checked', false);
		} else {
			$(this).prop('checked', true);
		}
	});
	calc_money();
});
$('.select_checkbox_one2').click(function() {

	if ($('.select_checkbox_one2').length == $('input[name="select_check2"]:checked').length) {
		$('.select_checkbox_all2').prop('checked', true);
	} else {
		$('.select_checkbox_all2').prop('checked', false);
	}
	
	calc_money();
});







// 第一个页面

var calc_money = function () {
	var select_total = 0;
	$('input[name="select_check"]:checked').each(function(){ 
		var withdraw_money = $(this).closest('tr').find('.sell_money').html();
		withdraw_money = parseInt(withdraw_money);
		select_total += withdraw_money;
	}); 
	
	$('input[name="select_check2"]:checked').each(function(){ 
		var withdraw_money = $(this).closest('tr').find('.sell_money').html();
		withdraw_money = parseInt(withdraw_money);
		select_total += withdraw_money;
	}); 
	
	$('input[name="select_check3"]:checked').each(function(){ 
		var withdraw_money = $(this).closest('tr').find('.sell_money').html();
		withdraw_money = parseInt(withdraw_money);
		select_total += withdraw_money;
	}); 
	
	$('input[name="select_check4"]:checked').each(function(){ 
		var withdraw_money = $(this).closest('tr').find('.sell_money').html();
		withdraw_money = parseInt(withdraw_money);
		select_total += withdraw_money;
	}); 
	$('.select_total').html(select_total);
};
$('.select_checkbox_all').click(function () {
	var t = $(this).prop('checked');
	if (t) {
		$('.select_checkbox_one').prop('checked', true);
	} else {
		$('.select_checkbox_one').prop('checked', false);
	}
	calc_money();
});
// 反选
$('.select_checkbox_back_all').click(function () {
	var ttt = {};
	$('input[name="select_check"]:checked').each(function(){ 
		ttt[$(this).val()] = '1';
	});
	
	$('input[name="select_check"]').each(function () {
		var i = $(this).val();
		if (ttt[i]) {
			$(this).prop('checked', false);
		} else {
			$(this).prop('checked', true);
		}
	});
	calc_money();
});
$('.select_checkbox_one').click(function() {

	if ($('.select_checkbox_one').length == $('input[name="select_check"]:checked').length) {
		$('.select_checkbox_all').prop('checked', true);
	} else {
		$('.select_checkbox_all').prop('checked', false);
	}
	
	calc_money();
});


